<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <script type="text/javascript" src="/javascripts/jquery.min.js"></script>
    <script type="text/javascript" src="/javascripts/bootstrap.js"></script>
    <link rel="stylesheet" href="/stylesheets/bootstrap.css">
    <link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
<% include header.ejs %>

<div class="container">
    <form id="myForm" class="form-horizontal" action="/users/addUser" method="post">
        <div class="form-group">
            <label for="name" class="col-sm-1 control-label">姓名</label>
            <div class="col-sm-11">
                <input type="text" class="form-control" id="name" name="name" placeholder="Name">
            </div>
        </div>
        <div class="form-group">
            <label for="age" class="col-sm-1 control-label">年龄</label>
            <div class="col-sm-11">
                <input type="text" class="form-control" id="age" name="age" placeholder="Age">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-1 col-sm-11">
                <button id="sub" type="button" class="btn btn-default">添加</button>
            </div>
        </div>
    </form>
</div>
<!-- /.container -->
<script>
    $("#sub").click(function(){
        var name=$("#name").val();
        var age=$("#age").val();
        if($.trim(name)==null||$.trim(name)==''){
            alert('name不能为空')
        }else if($.trim(age)==null||$.trim(age)==''){
             alert('age不能为空');
        }else{
            $("#myForm").submit();
        }

    });
</script>

</body>
</html>